<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class A_subsidi extends CI_Controller {

	function __construct() {
        parent::__construct();	
        $this->load->model("master/master_instansi");
		$this->load->model("atur/atur_subsidi"); 
	}
	
	function index()
	{
		$data['judul'] = "Pengaturan Subsidi";
		$data['list'] = $this->atur_subsidi->subsidi();
		$data['list_i'] = $this->master_instansi->read();
		$data['main_view']='atur/subsidi/subsidi';
		$this->load->view('index',$data);		
	}
	
	function save()
	{
		$tgl_terima = $this->input->post('tgl_terima');
		$dateTerima = str_replace('/', '-', $tgl_terima);
		$tglMySQLT = date('Y-m-d', strtotime($dateTerima));

		$dataInsert = array(
			'nama_subsidi' => $this->input->post('nama_subsidi'),
			'id_m_instansi' => $this->input->post('id_m_instansi'),
			'total_subsidi' => $this->input->post('total_subsidi'),
			'tgl_terima' => $tglMySQLT,
			'ket' => $this->input->post('ket')
		);
		$this->atur_subsidi->save($dataInsert);
	}	
	
	function delete()
	{
		$id_a_subsidi = $this->input->post('id_a_subsidi');
		$this->atur_subsidi->delete($id_a_subsidi);
	}
	
	function refresh()
	{
		$data['list'] = $this->atur_subsidi->subsidi();
		$this->load->view('atur/subsidi/refresh', $data);		
	}
	
}